﻿var ScheduleTimes = {
    CreateScheduleTime: function () {
        $("button#AddScheduleTime").click(function () {
            var seminarScheduleID = $(this).attr("seminarScheduleID");
            var startHour = $("select#BeginHour").val();
            var startMinute = $("select#BeginMinute").val();
            var endHour = $("select#EndHour").val();
            var endMinute = $("select#EndMinute").val();
            var description = $("textarea#Description").val();
            $("div#dialog-loading").css("width", $("div#dialog-loading").parent().width());
            $("div#dialog-loading").css("height", $("div#dialog-loading").parent().height());
            $("div#dialog-loading").css("display", "block");
            $.ajax({
                url: "/Course/CreateScheduleTime",
                type: "POST",
                data: { "seminarScheduleID": seminarScheduleID, "startHour": startHour, "startMinute": startMinute,
                    "endHour": endHour, "endMinute": endMinute, "description": description
                },
                cache: false,
                dataType: "html",
                success: function (data) {
                    $("#dialog").html(data);
                    $("div#dialog-loading").css("display", "none");
                }
            });
        });
    },

    DeleteScheduleTime: function () {
        $("table.tbl1 span.delete_icon16").click(function () {
            var scheduleTimeID = $(this).parent().parent().attr("ScheduleTimeID");
            $("div#dialog-loading").css("width", $("div#dialog-loading").parent().width());
            $("div#dialog-loading").css("height", $("div#dialog-loading").parent().height());
            $("div#dialog-loading").css("display", "block");
            $.ajax({
                url: "/Course/DeleteScheduleTime",
                type: "POST",
                data: { "scheduleTimeID": scheduleTimeID },
                cache: false,
                dataType: "html",
                success: function (data) {
                    $("#dialog").html(data);
                    $("div#dialog-loading").css("display", "none");
                }
            });
        });
    },

    init: function () {
        ScheduleTimes.CreateScheduleTime();
        ScheduleTimes.DeleteScheduleTime();
    }
}